package com.mstore.interceptor;

import java.util.Map;

import com.mstore.pojo.Account;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

public class AccountInterceptor extends AbstractInterceptor {

	private static final long serialVersionUID = -5481728968813966421L;

	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		
		// 取得请求相关的ActionContext实例
		ActionContext ctx = invocation.getInvocationContext();
		Map<String, Object> session = ctx.getSession();
		Object object = session.get("account");
		if (object instanceof Account) {
			return invocation.invoke();
		}
		return "toLigin";
	}

}
